package com.azxcrm.project.system.product.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.project.system.product.dao.IProductSpecificationDao;
import com.azxcrm.project.system.product.domain.ProductSpecification;
import com.azxcrm.project.system.product.service.IProductSpecificationService;

/**
 * 产品品种 服务层实现
 * 
 * @author Dustyone
 * @date 2018-09-04
 */
@Service
public class ProductSpecificationServiceImpl implements IProductSpecificationService 
{
	@Autowired
	private IProductSpecificationDao productSpecificationDao;
	
	/**
     * 查询产品品种信息
     * 
     * @param specId 产品品种ID
     * @return 产品品种信息
     */
	 @Override
	public ProductSpecification selectProductSpecificationById(Integer specId)
	{
	    return productSpecificationDao.selectProductSpecificationById(specId);
	}
	
	/**
     * 查询产品品种列表
     * 
     * @param productSpecification 产品品种信息
     * @return 产品品种集合
     */
	 @Override
	public List<ProductSpecification> selectProductSpecificationList(ProductSpecification productSpecification)
	{
	    return productSpecificationDao.selectProductSpecificationList(productSpecification);
	}
	
    /**
     * 新增产品品种
     * 
     * @param productSpecification 产品品种信息
     * @return 结果
     */
	 @Override
	public int insertProductSpecification(ProductSpecification productSpecification)
	{
	    return productSpecificationDao.insertProductSpecification(productSpecification);
	}
	
	/**
     * 修改产品品种
     * 
     * @param productSpecification 产品品种信息
     * @return 结果
     */
	 @Override
	public int updateProductSpecification(ProductSpecification productSpecification)
	{
	    return productSpecificationDao.updateProductSpecification(productSpecification);
	}
	
	/**
     * 保存产品品种
     * 
     * @param productSpecification 产品品种信息
     * @return 结果
     */
	 @Override
	public int saveProductSpecification(ProductSpecification productSpecification)
	{
		
	    Integer specId = productSpecification.getSpecId();
		int rows = 0;
		if (StringUtils.isNotNull(specId))
        {
		    rows = productSpecificationDao.updateProductSpecification(productSpecification);
		}
		else
        {
		    rows = productSpecificationDao.insertProductSpecification(productSpecification);
		}
		return rows;
	}
	
	/**
     * 删除产品品种信息
     * 
     * @param specId 产品品种ID
     * @return 结果
     */
	 @Override
	public int deleteProductSpecificationById(Integer specId)
	{
	    return productSpecificationDao.deleteProductSpecificationById(specId);
	}
	
	/**
     * 批量删除产品品种对象
     * 
     * @param specIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteProductSpecification(Integer[] specIds)
	{
		return productSpecificationDao.batchDeleteProductSpecification(specIds);
	}
	
}
